package cn.dengta.webapp.risk.bean;

import javax.annotation.Nullable;

import cn.dengta.common.model.ValueProxy;
import cn.dengta.common.model.ValueProxyImpl;
import cn.dengta.common.util.Common;
import lombok.Getter;

/**
 * 风控业务类型标签
 *
 * @author ZW
 * @since 2023 03-28
 */
@Getter
public enum BusinessTag implements ValueProxyImpl<BusinessTag, Integer> {

	FACE(0, "FACEDETECTION", "不露脸"),
	GENDER(1, "GENDER", "性别不符"),
	BLANK(2, "LOWVISION", "黑屏");

	public final String alias;
	public final Integer value;
	final ValueProxy<BusinessTag, Integer> proxy;

	BusinessTag(Integer value, String alias, String label) {
		this.alias = alias;
		this.value = value;
		this.proxy = new ValueProxy<>(this, value, label);
	}

	public static final BusinessTag[] CACHE = values();

	public static BusinessTag of(@Nullable Integer value) {
		return Common.getEnum(CACHE, BusinessTag::getValue, value);
	}

	public static BusinessTag ofAlias(String alias) {
		for (BusinessTag tag : CACHE) {
			if (tag.alias.equals(alias)) {
				return tag;
			}
		}
		return null;
	}
}
